package umls.interfaces;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;

import javax.xml.namespace.QName;


import umls.interfaces.pubmed.jaxb.PubMedProxyImpl;
import umls.interfaces.pubmed.jaxb.PubMedService;




public class PubMed {
	private URL url;
	PubMedService service;
	PubMedProxyImpl  port;

	public PubMed(String service_adress) throws MalformedURLException {
		url = new URL(service_adress);
		String wsdlname = url.getFile();
		if (wsdlname.equals("") || wsdlname == null) {
			System.out.println(service_adress + " non è valido");
			System.exit(2);
		}
		 service = new PubMedService(url, new QName(
                 "http://jaxws.server.pubmed.interfaces.umls/",
                 "PubMedService"));
		 port = service.getPubMedService();
	}

	public List<String> getTerm(List<String> genes, String process) {
		List<String> tmp = null;
		try {
			System.out.println("Provo ad inviare query " + process + " con "
					+ genes.size() + " geni");
			tmp = port.getPreferredNames(process, genes);
			
		} catch (Exception e) {
			System.out.println(e.getMessage());
			System.exit(2);
		}
		return tmp;
	}

}
